package com.yyfax.account.configuration;

import com.alibaba.druid.pool.DruidDataSource;
import com.yyfax.account.common.plugin.MySQLDialect;
import com.yyfax.account.common.plugin.PageInterceptor;
import org.apache.ibatis.plugin.Interceptor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * 账户配置类，代替xml
 *
 * @author liangqm
 * @date 2018/3/23 18:29
 * @since v1.0.0
 */
@Configuration
public class AccountConfiguration {


	@Bean
	@ConfigurationProperties(prefix = "spring.datasource.account")
	@Primary
	public DataSource dataSource() {
		DruidDataSource datasource = new DruidDataSource();
		return datasource;
	}

	@Bean
	public Interceptor pageInterceptor() {
		return new PageInterceptor(new MySQLDialect());
	}
}
